home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-11 / fprotems.zip / PROPOPS.TLB < prev    next >
Text File  |  1993-01-04  |  4KB  |  181 lines

  1. <<title Foxpro popup library for PROPOPS.TEM Author: Ellen Sander>>
  2.  
  3. <<uicode>>
  4. * PROPOPS.TLB
  5. * Last modified 12/19/89
  6. ********************************
  7. function declare_all_popboxes **
  8. ********************************
  9. * Writes the interior of the popmenu after
  10. * calling declare_popbox to write the box itself.
  11. param b,n
  12. private pm
  13.  
  14. for all boxes where is_menu(box)
  15.    menubox = box
  16.    pm = number_of_options_in_box(menubox)  
  17.    declare_popbox(menubox,n,pm)            
  18.                                       
  19.    if pm > 1     ** popup menu ordinaire
  20.       for all options in box 
  21.      
  22.          ?  'DEFINE BAR {count} OF {box.name} PROMPT '
  23.          ??  {digest_text(box_text(option,0,0))}
  24.         
  25.           if ! empty(option.message)
  26.             * MESSAGE and SKIP [FOR] slot for menu prompt.
  27.             ?? " ;"
  28.             ?
  29.               munch_slot(option.message)
  30.           endif
  31.           
  32.       endfor     
  33.      
  34.    endif
  35.    
  36.    if pm = 1   ** variable size popup has only one option in box
  37.    
  38.       * PROMPT FIELDS | FILES | STRUC from option action line 1
  39.       if ! empty(option.action[1])
  40.  
  41.         if at("PROMPT", upper(option.action[1]))
  42.            autopop_expr = strtran(upper(option.action[1]),'PROMPT', " ")
  43.         else
  44.            autopop_expr =  option.action[1]
  45.         endif
  46.         
  47.         ?? " ;"
  48.         ? 'PROMPT {autopop_expr}'
  49.       endif
  50.      
  51.    endif
  52.    
  53.    ? "ON SELECTION POPUP {box.name} DEACTIVATE POPUP"
  54.    ?
  55. next
  56.  
  57. return
  58.  
  59. **************************
  60. function declare_popbox **
  61. **************************
  62. * Defines the menu box itself, it's message and color scheme #.
  63. param b,n,pm
  64. private numopts
  65.  
  66. ? "* Definition for {b.name}"
  67. if ! empty(b.descrip)
  68.    ? "* {b.descrip}"
  69. endif
  70.  
  71. ? "DEFINE POPUP {b.name} FROM {b.row}, {b.col}"
  72.  
  73. if pm >1
  74.    ?? " TO {b.bottom}, {b.right} "
  75. endif
  76. if ! empty(box.slot1)
  77.    * Menubox message slot.
  78.    ?? "; "
  79.    ?
  80.    munch_slot(box.slot1)
  81. endif   
  82.  
  83. ?? " ;"
  84. ?  "COLOR SCHEME {n}"
  85.  
  86. return
  87.  
  88. *******************
  89. function is_menu **
  90. *******************
  91. * If Mr. Box has options, it's a menu.  If not, ignore it.
  92. param b
  93. for all options in b
  94.   return .t.
  95. endfor
  96. return .f.
  97.  
  98. **********************
  99. function munch_slot **
  100. **********************
  101. param sl
  102. private s_tokes,i
  103. * Tidies up your generated code by thoughtfully breaking a line
  104. * wherever you may have typed a semi colon in the slot.
  105. * For you mega-expression mavens.
  106.  
  107. s_tokes = get_tokens("{sl}", '" ; ')
  108.  
  109. for i = 1 to len(s_tokes)
  110.  
  111.    if i = len(s_tokes)
  112.       ?? "{s_tokes[i]}"
  113.    else
  114.       ?? "{s_tokes[i]} "
  115.    endif
  116.    
  117.    if s_tokes[i] = ";"
  118.       ?
  119.    endif
  120.    
  121. next
  122.  
  123. return
  124.  
  125. ***********************
  126. function digest_text **
  127. ***********************
  128. * A genuine Wallsoft original
  129. * This little gem manages quotation marks and control chars in a string.
  130. param s
  131. private i,lquote,rquote
  132.  
  133. if at('"',s)               
  134.   if at("'",s)               
  135.     if at("[",s) .or. at("]",s)   
  136.       s=strtran(s,'"','"+%'"%'+"')
  137.       lquote='"'           
  138.       rquote='"'
  139.     else                     ** no brackets, use them
  140.       lquote='['
  141.       rquote=']'
  142.     endif
  143.   else                       ** no singles, use them
  144.     lquote="'"
  145.     rquote="'"
  146.   endif
  147. else                         ** no doubles, use them
  148.   lquote='"'
  149.   rquote='"'
  150. endif
  151.  
  152. * and quote the string
  153. s=lquote+s+rquote
  154.  
  155. * check for control characters
  156. if ctrl_in_str(s)
  157.   if asc(s[2])<32             ** check first character
  158.     s = "chr("+asc(s[2])+")+"+lquote+substr(s,3)
  159.   endif
  160.  
  161.   if asc(s[len(s)-1])<32         ** check last character
  162.     s = substr(s,1,len(s)-2)+rquote+"+chr("+asc(s[len(s)-1])+")"
  163.   endif
  164.  
  165.   for i=3 to len(s)-2        ** scan interior
  166.     if asc(s[i])<32
  167.       ** break control char into '...+chr(n)+...' format
  168.       s=substr(s,1,i-1)+rquote+"+chr("+asc(s[i])+")+"+lquote+substr(s,i+1)
  169.  
  170.       i=i+7+(asc(s[i])>9)    ** compensate for length increase in s
  171.     endif
  172.   endfor
  173.  
  174.   * remove any embedded null concatenations
  175.   s=strtran(s,'+{lquote}{rquote}+','+')
  176. endif
  177.  
  178. return s
  179.  
  180. <<enduicode>>
  181.